import echarts from "@/plugins/echarts/install";
import { ILegendUpdater } from "@/plugins/echarts/legend-updater";
import { EChartsInstance } from "echarts-for-react";
import EChartsReactCore from "echarts-for-react/lib/core";
import option from "./testData";

type BarWithLegendUpdater = {
  legendUpdater: ILegendUpdater
}

const Bar: React.FC<BarWithLegendUpdater> = ({
  legendUpdater
}) => {

  function onChartReady(chart: EChartsInstance) {
    legendUpdater.addCharts([chart])
  }

  return (
    <EChartsReactCore
      style={{ width: '600px', height: '400px' }}
      echarts={echarts}
      option={option}
      onChartReady={onChartReady}
    ></EChartsReactCore>
  )
}

export default Bar